package com.company.cm.cm.cm.weather_info.generated;

import com.company.cm.cm.cm.weather_info.WeatherInfo;
import com.company.cm.cm.cm.weather_info.WeatherInfoImpl;
import com.speedment.common.annotation.GeneratedCode;
import com.speedment.runtime.config.identifier.TableIdentifier;
import com.speedment.runtime.core.component.SqlAdapter;
import com.speedment.runtime.core.db.SqlFunction;

import java.sql.ResultSet;
import java.sql.SQLException;

import static com.speedment.common.injector.State.RESOLVED;
import static com.speedment.runtime.core.internal.util.sql.ResultSetUtil.*;

/**
 * The generated Sql Adapter for a {@link
 * com.company.cm.cm.cm.weather_info.WeatherInfo} entity.
 * <p>
 * This file has been automatically generated by Speedment. Any changes made to
 * it will be overwritten.
 * 
 * @author Speedment
 */
@GeneratedCode("Speedment")
public abstract class GeneratedWeatherInfoSqlAdapter implements SqlAdapter<WeatherInfo> {
    
    private final TableIdentifier<WeatherInfo> tableIdentifier;
    
    protected GeneratedWeatherInfoSqlAdapter() {
        this.tableIdentifier = TableIdentifier.of("cm", "cm", "weather_info");
    }
    
    protected WeatherInfo apply(ResultSet resultSet, int offset) throws SQLException {
        return createEntity()
            .setId(                  resultSet.getInt(1 + offset))
            .setStationNumber(       resultSet.getString(2 + offset))
            .setTemperature(         resultSet.getBigDecimal(3 + offset))
            .setCurrentWeather(      resultSet.getString(4 + offset))
            .setWindDirection(       getDouble(resultSet, 5 + offset))
            .setWindLevel(           getLong(resultSet, 6 + offset))
            .setPmLevel(             getFloat(resultSet, 7 + offset))
            .setRelaHumi(            getDouble(resultSet, 8 + offset))
            .setRainCount(           resultSet.getBigDecimal(9 + offset))
            .setCreateTime(          resultSet.getTimestamp(10 + offset))
            .setObservationDataDate( resultSet.getTimestamp(11 + offset))
            .setUpdateTime(          resultSet.getTimestamp(12 + offset))
            .setDeviceId(            getLong(resultSet, 13 + offset))
            .setCanopyTemperature(   getDouble(resultSet, 14 + offset))
            ;
    }
    
    protected WeatherInfoImpl createEntity() {
        return new WeatherInfoImpl();
    }
    
    @Override
    public TableIdentifier<WeatherInfo> identifier() {
        return tableIdentifier;
    }
    
    @Override
    public SqlFunction<ResultSet, WeatherInfo> entityMapper() {
        return entityMapper(0);
    }
    
    @Override
    public SqlFunction<ResultSet, WeatherInfo> entityMapper(int offset) {
        return rs -> apply(rs, offset);
    }
}